export function dateFormater(time,flag,toSecond) {
  let date = new Date(time);
  let y = date.getFullYear();
  let m = date.getMonth() + 1;
  let hours = date.getHours();
  const minutes = date.getMinutes()<10? '0'+date.getMinutes():date.getMinutes();
  const seconds = date.getSeconds();
  hours = hours < 10 ? "0" + hours : hours;
  m = m < 10 ? "0" + m : m;
  let d = date.getDate();
  d = d < 10 ? "0" + d : d;
  if(toSecond){
    return y + "-" + m + "-" + d +' ' + hours + ':' + minutes + ':' +seconds;
  }
  if(flag){
    return y + "-" + m + "-" + d +' ' + hours + ':' + minutes ;
  }else{
    return y + "-" + m + "-" + d ;
  }
  
}

export default dateFormater;
